<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\GoldRecord;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;
use Rainsens\Dinglog\Facades\Dinglog;
use App\Jobs\CheckGoldRecordJob;

class CheckGoldRecord extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cc:check-gold-record';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {

        $times = 180 / 3;
        $delayTimes = [];
        for ($i = 0; $i < $times; $i++) {
            $delayTimes[] = $i * 3;
        }

        $queue = app()->environment('local') ? 'default' : 'default';
         foreach ($delayTimes as $delay) {
             dispatch(new CheckGoldRecordJob())->onQueue($queue)->delay(now()->addSeconds($delay));
        }
       
    }
}
